package com.sora.novel.search.controller.front;

import com.sora.novel.book.dto.req.BookSearchReqDto;
import com.sora.novel.book.dto.resp.BookInfoRespDto;
import com.sora.novel.common.constant.ApiRouterConsts;
import com.sora.novel.common.resp.PageRespDto;
import com.sora.novel.common.resp.RestResp;
import com.sora.novel.search.service.SearchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname: SearchController
 * @Description: 前台门户-搜索模块 API 控制器
 * @Author: Stonffe
 * @Date: 2023/6/21 14:25
 */
@Tag(name = "SearchController", description = "前台门户-搜索模块")
@RestController
@RequestMapping(ApiRouterConsts.API_FRONT_SEARCH_URL_PREFIX)
@RequiredArgsConstructor
@Slf4j
public class SearchController {
    private static final Logger logger = LoggerFactory.getLogger(SearchController.class);

    private final SearchService searchService;

    /**
     * 小说搜索接口
     */
    @Operation(summary = "小说搜索接口")
    @GetMapping("books")
    public RestResp<PageRespDto<BookInfoRespDto>> searchBooks(
            @ParameterObject BookSearchReqDto condition) {
        RestResp<PageRespDto<BookInfoRespDto>> res = searchService.searchBooks(condition);
        logger.info("分类查询结果：{}",res);
        return res;
    }
}
